package com.example.mobile2030606162zwh0420;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class Prat_main {
    public static class PartRVAdapter extends RecyclerView.Adapter<PartRVAdapter.ViewHolder> {
        int[] partIds;
        String[] Partname;

        public PartRVAdapter(int[] partIds, String[] Partname) {
            this.partIds = partIds;
            this.Partname = Partname;
        }

        @NonNull
        @Override
        public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_rv_main_part,parent,false);
            return new ViewHolder(view);
        }

        @Override
        public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
            holder.Image_two_two.setImageResource(partIds[position]);
            holder.Text_two_two.setText(Partname[position]);
        }

        @Override
        public int getItemCount() {
            return partIds.length;
        }

        static class ViewHolder extends RecyclerView.ViewHolder {
            TextView Text_two_two;
            ImageView Image_two_two;

            public ViewHolder(@NonNull View itemView) {
                super(itemView);
                this.Text_two_two = itemView.findViewById(R.id.tv_item_part);
                this.Image_two_two = itemView.findViewById(R.id.iv_item_part);
            }
        }
    }
}